
JavaScript have only one type of number which is use to ‘var’ keyword. JavaScript automatic type cast the number by the right side of the value. This JavaScript value always 64bit. maximum number of decimals is 17 digits after ‘.’ symbol. In the JavaScript use the ‘+’ symbol to add the number and concatenated the string. Numbers are added. Strings are concatenated. We can NaN in our mathematical operations. If you use NaN in a mathematical operation, the result will also be NaN. Now given bellow the number example code and explain the code:
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<script type="text/javascript">
// Use Number
var a=15;
var b=10;
var c=12;
//add
var x=a+b;
//Sub
var y=a-c;
//Sub
var z=b*c;
//print the out put:
console.log("Value of x: "+x);
console.log("Value of y: "+y);
console.log("Value of z: "+z);
</script>
</body>
</html>
In the JavaScript code we perform the arithmetic operation. First, we assign the value of the variables and then perform the arithmetic operation then store other variables and print the output of the operation by using “console.log” function.